<!--div class="container"-->
    <form method="post" id="formuser" action="#" enctype="multipart/form-data" class="form-horizontal" role="form">
	<div class="col-md-offset-1">
        <div class="col-md-11">			
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title"><b class="caret"></b><b> Form - Add Master Item</b></h4>
				</div>
				<div class="panel-body">
					<div class="col-sm-8">
						<div class="col-sm-4"><label for="l_item" class="control-label">Item Name<span style="color:red;">*</span></label></div>
						<div class="col-sm-4"><input type="text" class="form-control input-sm required" id="item" name="item" maxlength="30"></div>
					</div>
					<div class="col-sm-8">
						<div class="col-sm-4"><label for="l_quantity" class="control-label">Item Qty<span style="color:red;">*</span></label></div>
						<div class="col-sm-3"><input type="text" class="form-control input-sm required" id="quantity" name="quantity" value="1"></div>
					</div>
					<div class="col-sm-8">
						<div class="col-sm-4"><label for="l_uom" class="control-label">Item Uom</label></div>
						<div class="col-sm-3"><input type="text" class="form-control input-sm" id="uom" name="uom" value="Each"></div>
					</div>
					<div class="col-sm-8">
						<div class="col-sm-4"><label for="l_status" class="control-label">Item Status</label></div>
						<div class="col-sm-3">
							<select name="status" id="status" class="form-control input-sm">
								<option value="Y">Active</option>
								<option value="N">Not Active</option>						
							</select>
						</div>
					</div>			
					<div class="col-sm-8" style="padding-bottom: 10px;">
						<div class="col-sm-4">
							&nbsp;
						</div>
					</div>
					<div class="col-sm-8">
						<!--div class="col-sm-4"><label for="button" class="control-label">&nbsp;</label></div-->
						<div class="col-sm-4">
							<a class="btn btn-block btn-info" href="#" onclick="view_detail();">
								<!--span class="glyphicon glyphicon-eye-open"></span--> View Master List</a>
						</div>
						<div class="col-sm-4">
							<button type="submit" class="btn btn-success btn-block"><!--span class="glyphicon glyphicon-saved"></span--> Save Add</button>
						</div>
						<div class="col-sm-4">
							<button type="button" class="btn btn-default btn-block" onclick="cancel();"><!--span class="glyphicon glyphicon-circle-arrow-left"></span--> Cancel</button>
						</div>
					</div>
				</div>
			</div>
		</div>
    </form>
	</div>
<!--/div-->
<!--div style="margin-top:20px;"></div--->
<script type="text/javascript">
    $.validator.setDefaults({
        submitHandler: function() {
            $.post("<?= site_url() ?>setup/insert_room_item", {
                item: $('#item').val(),
                quantity: $('#quantity').val(),
				uom: $('#uom').val(),
				status: $('#status').val()				
            },
            function(data) {
                window.location = '<?php echo base_url();?>setup/room';
            });
        }
    });

    $(document).ready(function() {
        $("#formuser").keypress(function(e) {
            if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
                $.validator.setDefaults({
                    submitHandler: function() {
                        $.post("<?= site_url() ?>setup/insert_room_item", {
                            item: $('#item').val(),
							quantity: $('#quantity').val(),
							uom: $('#uom').val(),
							status: $('#status').val()
                        },
                        function(data) {
                            window.location = '<?php echo base_url();?>setup/room';
                        });
                    }
                });
            }
        });

        $("#formuser").validate();
    });

    function cancel() {
        $.post("<?= site_url() ?>setup/result_room", function(data) {
            window.location = '<?php echo base_url();?>setup/room';
        });
    }
	
	function view_detail() {
		$.post("<?= site_url() ?>setup/view_master_item", function(data) {
            $('#loader').html(data);
        });
	}
	
</script>